package org.finesys.system.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.finesys.common.constants.CacheConstants;
import org.finesys.common.mp.core.service.impl.BaseServiceImpl;
import org.finesys.system.api.entity.SysUserRole;
import org.finesys.system.mapper.SysUserRoleMapper;
import org.finesys.system.service.SysUserRoleService;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Caching;
import org.springframework.stereotype.Service;

@Service
public class SysUserRoleServiceImpl extends BaseServiceImpl<SysUserRoleMapper, SysUserRole> implements SysUserRoleService {
    /**
     * 根据 roleId 删除对应的用户角色信息
     */
    @Override
    @Caching(evict = {
            @CacheEvict(value = CacheConstants.MENU_DETAILS, key = "#roleId")
    })
    public void deleteUserRoleByRoleId(Long roleId) {
        baseMapper.delete(Wrappers.<SysUserRole>update().lambda().eq(SysUserRole::getRoleId, roleId));
    }
}
